package com.jdj.framework;

import java.util.concurrent.CountDownLatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

/**
 * 服务启动
 * @author caijinbang
 * @date 2019-04-14 15:07
 */
@SpringBootApplication
public class Application4BaseService {
    private static Logger logger = LoggerFactory.getLogger(Application4BaseService.class);

    @Bean
    public CountDownLatch closeLatch() {
        return new CountDownLatch(1);
    }

    public static void main(String[] args) throws InterruptedException {
        ApplicationContext ctx = new SpringApplicationBuilder().sources(Application4BaseService.class).web(
            WebApplicationType.NONE).run(args);
        logger.info("启动完成！");
        CountDownLatch closeLatch = ctx.getBean(CountDownLatch.class);
        closeLatch.await();
    }
}
